<?php
session_start();
require_once substr(dirname(__FILE__),0,-1).'sub/init.php';
if(@!in_array('party',$navarr))exit('该功能已关闭');
if (!ifint($fid))alert('活动不存在',mHref('party'));
if (empty($cook_openid) && is_weixin()){
	$cook_openid=wx_get_openid();
}
//报名人数上限，不能报名
require_once ZEAI.'sub/conn.php';
require_once ZEAI.'cache/config_sms.php';
require_once ZEAI.'cache/config_vip.php';
require_once ZEAI.'sub/www_zeai_cn_sms.php';
if($submitok == 'ajax_bm_add'){//step 2 前置检查
	$rowf = $db->ROW(__TBL_PARTY__,"title,ifpay","flag=1 AND id=".$fid,'name');
	if (!$rowf){
		if($js==1){
			json_exit(array('flag'=>0,'msg'=>'报名已经结束'));
		}else{
			zeaialert('{"title":"报名已经结束","btnt":"我知道了","url":"-1"}');
		}
	}
	$SQL = (ifint($cook_uid))?" OR uid=$cook_uid":"";
	$row2 = $db->ROW(__TBL_PARTY_USER__,"ifpay","(mob='".$cook_mob."' AND mob<>'' ".$SQL.") AND fid=".$fid);
	if ($row2){
		$paystr=($row2['ifpay']==1)?'（报名费已交）':'';
		if($js==1){
			json_exit(array('flag'=>0,'msg'=>'亲，您已经报过名了哦'.$paystr));
		}else{
			zeaialert('{"title":"您已经报过名了'.$paystr.'","btnt":"我知道了","url":"-1"}');
		}
	}
	//报名会员组权限
	$party_joingrade = json_decode($_VIP['party_joingrade'],true);
	if(!empty($_VIP['party_joingrade']) && @is_array($party_joingrade) && @count($party_joingrade)>0){
		if(!iflogin() || !ifint($cook_uid)){
			if($js==1){
				json_exit(array('flag'=>'nologin','jumpurl'=>mHref('party',$fid)));
			}else{
				header("Location: ".HOST.'/m/login.php?jumpurl='.urlencode(mHref('party',$fid)));
			}
		}
		$row = $db->ROW(__TBL_USER__,"grade","id=".$cook_uid,"num");
		$cook_grade= $row[0];
		if(!in_array($cook_grade,$party_joingrade)){
			$urole = json_decode($_ZEAI['urole']);
			foreach (@$party_joingrade as $g){
				$party_joingrade_str.='【'.utitle($g).'】';
			}
			if(empty($party_joingrade_str))$party_joingrade_str='VIP';
			if($js==1){
				json_exit(array('flag'=>'nolevel','msg'=>'亲，只有'.$party_joingrade_str.'才可以参加活动哦<br><font class=\'zeaicolor\'>您当前是【'.utitle($cook_grade).'】</font>','jumpurl'=>mHref('party',$fid)));
			}else{
				zeaialert('{"title":"亲，只有'.$party_joingrade_str.'才可以参加活动哦<br><font class=\'zeaicolor\'>您当前是【'.utitle($cook_grade).'】</font>","btnt":"我知道了","url":"'.mHref('party',$fid).'"}');
			}
		}
	}
	if($js==1)json_exit(array('flag'=>1));
}
if($submitok == 'ajax_bbs_add_update' ){//|| ifint($cook_uid)
	$currfields = "sex,mob,weixin,truename,birthday";
	$$rtn='json';$chk_u_jumpurl=mHref('party',$fid);
	require_once ZEAI.'m/my_chk_u.php';
}
if($submitok == 'ajax_bbs_add_update'){
	if (empty($content))json_exit(array('flag'=>0,'msg'=>'请输入内容'));
	if ($cook_content == $content && !empty($content))json_exit(array('flag'=>0,'msg'=>'请不要重复发表'));
	$row = $db->NAME($cook_uid,"nickname,sex,grade,photo_s,photo_f,photo_ifshow,flag");
	if ($row){
		$sex      = $row['sex'];
		$photo_s  = $row['photo_s'];
		$photo_f  = $row['photo_f'];
		$photo_ifshow  = $row['photo_ifshow'];
		$uflag  = $row['flag'];
		$grade    = $row['grade'];
		$nickname = dataIO($row['nickname'],'out');
		$photo_s_url=photo_s_out('{"smb":"s","sex":"'.$sex.'","photo_s":"'.$photo_s.'","photo_f":"'.$photo_f.'","photo_ifshow":"'.$photo_ifshow.'","uflag":"'.$uflag.'","outkind":"url"}');
		$addtime    = date_str(ADDTIME-1);
		$echo .= '<dl>';
		$echo .= '<dt onClick="PTuA('.$cook_uid.');"><img src="'.$photo_s_url.'"'.$sexbg.'></dt>';
		$echo .= '<dd>';
		$echo .= '<h6>'.uicon($sex.$grade).$nickname.'</h6>';
		$echo .= '<em>'.$content.'</em>';
		$echo .= '<span>'.$addtime.'</span>';
		$echo .= '</dd>';
		$echo .= '</dl>';
	}
	$content = dataIO($content,'in',5000);
	$db->query("INSERT INTO ".__TBL_PARTY_BBS__." (uid,fid,content,addtime) VALUES ($cook_uid,$fid,'$content',".ADDTIME.")");
	$db->query("UPDATE ".__TBL_PARTY__." SET bbsnum=bbsnum+1 WHERE id=".$fid);
	setcookie("cook_content",$content,time()+720000,"/",$_ZEAI['CookDomain']);
	json_exit(array('flag'=>1,'msg'=>'发表成功','list'=>dataIO($echo,'in')));
}elseif($submitok == 'ajax_party_getBMulist'){
	$ret = party_getBMulist($fid);
	json_exit(array('flag'=>1,'total'=>$ret['total'],'list'=>dataIO($ret['list'],'in')));
}elseif($submitok == 'ajax_bm_ifpay'){//step 1检查是否报过名，缴过费
	$rowf = $db->ROW(__TBL_PARTY__,"title,ifpay","flag=1 AND id=".$fid,'name');
	if (!$rowf)json_exit(array('flag'=>0,'msg'=>'活动已经结束'));
	$row2 = $db->ROW(__TBL_PARTY_USER__,"ifpay","mob='".$cook_mob."' AND mob<>'' AND fid=".$fid);
	if ($row2){
		if($rowf['ifpay']==1 && $row2['ifpay']==0){
			//已报名未缴费，跳转交费页面
			json_exit(array('flag'=>0,'ifpay'=>1,'msg'=>'您已经报名成功，请在线支付报名费'));
		}
	}
	json_exit(array('flag'=>0,'ifpay'=>0));
exit;}elseif($submitok == 'ajax_get_verify_self'){//step 2_mobyzm↑
	if(!ifmob($mob)){
		json_exit(array('flag'=>0,'msg'=>'手机号码不正确'));
	}else{
		$SQL = (ifint($cook_uid))?" OR uid=$cook_uid":"";
		if ($db->ROW(__TBL_PARTY_USER__,"id","(mob='$mob'".$SQL.") AND fid=".$fid)){
			setcookie("cook_mob",$mob,time()+720000,"/",$_ZEAI['CookDomain']);
			json_exit(array('flag'=>0,'msg'=>'您已经报过名了，请不要重复报名'));
		}
	}
	if ($Temp_regyzmrenum > $_SMS['sms_yzmnum'] && $_SMS['sms_yzmnum']>0 )json_exit(array('flag'=>0,'msg'=>'你重复发送次数过多，请明天再试'));
	$_SESSION['Zeai_cn__verify'] = cdstr(4);
	//sms
	$rtn = Zeai_sendsms_authcode($mob,$_SESSION['Zeai_cn__verify']);
	if ($rtn == 0){
		setcookie("Temp_regyzmrenum",$Temp_regyzmrenum+1,time()+720000,"/",$_ZEAI['CookDomain']);
		$chkflag = 1;
		$content = '验证码发送成功，请注意查收';
	}else{
		$chkflag = 0;
		$content = "发送失败：".sms_error($rtn);
	}
	//sms end
	$_SESSION['Zeai_cn__mob'] = $mob;
	json_exit(array('flag'=>$chkflag,'msg'=>$content));
}elseif($submitok == 'ajax_bm_add_update'){//step 2
	//人数限定
    $sex=intval($sex);
	$rowf = $db->ROW(__TBL_PARTY__,"flag,ifpay,title,ifadmlist,num_n,num_r","flag=1 AND id=".$fid,'name');
	if (!$rowf)json_exit(array('flag'=>0,'msg'=>'活动已经结束'));
	if($sex==2){
	    $data_num=$rowf['num_r'];
	}else{
	    $data_num=$rowf['num_n'];
	}
    $sexnum = $db->COUNT(__TBL_PARTY_USER__,"sex=".$sex." AND fid=".$fid);
    if($sexnum>=$data_num && $data_num>0)json_exit(array('flag'=>0,'msg'=>'报名人数已满，请下次早点报名哦<br>有问题可联系客服咨询！'));
    //
	if(!ifmob($mob))json_exit(array('flag'=>0,'msg'=>'请留下手机号码，方便活动通知您哦'));
	//验证码对比
	$verify = intval($verify);
	if (empty($_SESSION['Zeai_cn__verify'])){
		json_exit(array('flag'=>0,'msg'=>'短信验证码错误，请重新获取='.$_SESSION['Zeai_cn__verify']));
	}else{
		if ($_SESSION['Zeai_cn__verify'] != $verify){
			json_exit(array('flag'=>0,'msg'=>'短信验证码不正确'));
		}
		if ($_SESSION['Zeai_cn__mob'] != $mob && ifmob($mob)){
			unset($_SESSION["Zeai_cn__verify"]);
			unset($_SESSION["Zeai_cn__mob"]);
			setcookie("cook_mob",'',time()+720000,"/",$_ZEAI['CookDomain']);
			json_exit(array('flag'=>0,'msg'=>'手机号码异常，请重新获取'));
		}
	}
	if (empty($truename))json_exit(array('flag'=>0,'msg'=>'请输入【真实姓名】'));
	if (!ifint($birthday))json_exit(array('flag'=>0,'msg'=>'请输入【出生年份】'));
	$cook_mob=$mob;//2020-10-28
	$rowf = $db->ROW(__TBL_PARTY__,"flag,ifpay,title,ifadmlist","flag=1 AND id=".$fid,'name');
	if (!$rowf)json_exit(array('flag'=>0,'msg'=>'活动已经结束'));
	$ifpay=$rowf['ifpay'];$pttitle=trimhtml(dataIO($rowf['title'],'out'));$ifadmlist=$rowf['ifadmlist'];
	
	//2020-10-28
	$rowU = $db->ROW(__TBL_USER__,"id","FIND_IN_SET('mob',RZ) AND mob='$cook_mob'","num");
	if($rowU){
		$cook_uid = $rowU[0];
	}
	$cook_uid=intval($cook_uid);
	
	$SQL = (ifint($cook_uid))?" OR uid=$cook_uid":"";
	$row2 = $db->ROW(__TBL_PARTY_USER__,"ifpay","(mob='".$cook_mob."' AND mob<>'' ".$SQL.") AND fid=".$fid,'name');
	if ($row2){
		if($row2['ifpay']==1)json_exit(array('flag'=>0,'msg'=>'您已经报过名(费用已交)，无需再提交'));
		if($ifpay==1)json_exit(array('flag'=>1,'fid'=>$fid,'ifpay'=>1,'msg'=>'您已经报过名，请在线支付报名费'));
		json_exit(array('flag'=>0,'msg'=>'您已经报过名，请不要重复报名'));
	}else{
		$mob=dataIO($mob,'in',11);
		$weixin=dataIO($weixin,'in',50);
		$truename=dataIO($truename,'in',20);
		$sex=intval($sex);
		$sextitle=($sex==2)?'女':'男';
		$birthday=intval($birthday);
		$db->query("INSERT INTO ".__TBL_PARTY_USER__."  (uid,fid,flag,addtime,truename,birthday,sex,mob,weixin) VALUES ('$cook_uid','$fid',0,".ADDTIME.",'$truename','$birthday','$sex','$mob','$weixin')");
		$db->query("UPDATE ".__TBL_PARTY__." SET bmnum=bmnum+1 WHERE flag=1 AND id=".$fid);
		setcookie("cook_mob",$mob,time()+720000,"/",$_ZEAI['CookDomain']);
		setcookie("cook_truename",$truename,time()+720000,"/",$_ZEAI['CookDomain']);
		setcookie("cook_sex",$sex,time()+720000,"/",$_ZEAI['CookDomain']);
		//
		if(!empty($ifadmlist)){
			$rt=$db->query("SELECT openid,subscribe FROM ".__TBL_ADMIN__." WHERE id in ($ifadmlist) AND flag=1 AND subscribe=1 AND openid<>''");
			$total = $db->num_rows($rt);
			if ($total > 0) {
				for($i=1;$i<=$total;$i++) {
					$rows = $db->fetch_array($rt,'name');
					if(!$rows)break;
					$openid = $rows['openid'];$subscribe = $rows['subscribe'];
					if (!empty($openid) && $subscribe==1){
						$Ukindd=(ifint($cook_uid))?'[会员]':'[游客]';
						$Uinfo=$Ukindd.'性别：'.$sextitle.'　姓名：'.$truename.'　手机：'.$mob.'　微信：'.$weixin;
						$ret = @wx_kf_sent($openid,urlencode('有新的用户报名参加活动啦 -> 【'.$Uinfo.'】，来自活动【'.$pttitle.'】'),'text');
						$ret = json_decode($ret);
						if ($ret->errmsg != 'ok'){
							$first     = urlencode('有新的用户报名参加活动啦~~');
							$keyword1  = urlencode('活动报名');
							$keyword3  = urlencode($Uinfo);
							$remark    = '来自活动【'.$pttitle.'】';
							@wx_mb_sent('mbbh=ZEAI_ADMIN_INFO&openid='.$openid.'&keyword1='.$keyword1.'&keyword3='.$keyword3.'&time='.ADDTIME.'&first='.$first.'&remark='.$remark.'&url='.mHref('party',$fid));
						}
					}
				}
			}	
		}
	}
	json_exit(array('flag'=>1,'fid'=>$fid,'ifpay'=>$ifpay,'msg'=>'报名成功'));
}
/*********************** detail 初始化 ***************************/
if(!is_mobile())header("Location: ".Href('party',$fid));
$rt = $db->query("SELECT * FROM ".__TBL_PARTY__." WHERE flag>0 AND path_s<>'' AND id=".$fid);
if($db->num_rows($rt)){
	$row = $db->fetch_array($rt,'name');
	$path_s   = $row['path_s'];
	$pathlist = $row['pathlist'];
	$jzbmtime = $row['jzbmtime'];
	$flag     = $row['flag'];
	$click    = $row['click'];
	$ifpay = $row['ifpay'];
	$bmnum = $row['bmnum'];
	$signnum = $row['signnum'];
	$bbsnum  = $row['bbsnum'];
	$hdtime= dataIO($row['hdtime'],'out');
	$hdtime = str_replace(" 0时0分","",$hdtime);
	$address = dataIO($row['address'],'out');
	$title = trimhtml(dataIO($row['title'],'out'));
	$num_n = $row['num_n'];
	$num_r = $row['num_r'];
	$rmb_n = $row['rmb_n'];
	$rmb_r = $row['rmb_r'];
	$longitude= $row['longitude'];
	$latitude = $row['latitude'];
	$content  = trimhtml(dataIO($row['content'],'out'));$content = gylsubstr($content,100,0,"utf-8",false);
	$path_s_url = UP.$path_s;
	$path_b_url = smb($path_s_url,'b');
	$num_n_str=($num_n==0)?'<b>不限</b>':'<b>'.$num_n.'</b>人';
	$num_r_str=($num_r==0)?'<b>不限</b>':'<b>'.$num_r.'</b>人';
	$rmb_n_str=($rmb_n==0)?'<b class="C090">免费</b>':'<b>'.$rmb_n.'</b>元';
	$rmb_r_str=($rmb_r==0)?'<b class="C090">免费</b>':'<b>'.$rmb_r.'</b>元';	
	$bmnum_str=($bmnum>0)?'<b id="bmnum">'.$bmnum.'</b>':'';	
	$signum_str=($signnum>0)?'<b>'.$signnum.'</b>':'';	
	$bbsnum_str=($bbsnum>0)?'<b id="bbsnum">'.$bbsnum.'</b>':'';
	if($flag==1){
		$SQL = "";
		if(ifmob($cook_mob)){
			$SQL=" mob='".$cook_mob."' AND mob<>''";
		}else{
			if(ifint($cook_uid)){
				$roww = $db->ROW(__TBL_USER__,"mob","id=".$cook_uid,"name");
				if ($roww){
					$data_mob=$roww['mob'];
					if(ifmob($data_mob)){
						$SQL=" mob='".$data_mob."' AND mob<>''";
					}else{
						$SQL=" uid=$cook_uid";
					}
				}
			}
		}
		if(!empty($SQL)){
			$row2 = $db->ROW(__TBL_PARTY_USER__,"ifpay","fid=".$fid." AND ".$SQL,'name');
			if ($row2){
				$price=($cook_sex==1)?$rmb_n:$rmb_r;
				if($price>0){
					$bmbtn_str=($row2['ifpay']==1)?'已交费':'我要交费';
				}else{
					$bmbtn_str='免费参加';
					$bmbtn_cls=' class="free"';
				}
				if(!ifmob($cook_mob) && ifmob($data_mob)){
					setcookie("cook_mob",$data_mob,time()+720000,"/",$_ZEAI['CookDomain']);
				}
			}else{
				$bmbtn_str=$bmico.'我要报名';
			}
		}else{
			$bmbtn_str=$bmico.'我要报名';
		}
	}elseif($flag==2){
		$bmbtn_str='活动进行中';
		$bmbtn_cls=' style="background:#f80"';
	}else{
		$bmbtn_str='活动已结束';
		$bmbtn_cls=' style="background:#ccc"';
	}
	if($flag!=3){
		$difftime=ADDTIME-$jzbmtime;
		if($difftime>86400){
			$SQLL = ",flag=3";
		}elseif($difftime>0){
			$SQLL = ",flag=2";
		}
	}
	$db->query("UPDATE ".__TBL_PARTY__." SET click=click+1".$SQLL." WHERE id=".$fid);
} else {
	alert('活动不存在',mHref('party'));
}
switch ($submitok) {
	case 'ajax_bm_add':$headerT=$title;$mini_title = '填写报名资料';break;
	case 'ajax_bm_add_update_pay':$headerT=$title;$mini_title = '在线交费';break;
	default:$headerT=$title;$mini_title='活动详情';break;
}
function partyflag($flag) {
	switch ($flag){ 
		case 0:$flag_str = "<span class='partyflag0'>未审核</span>";break;
		case 1:$flag_str = "<span class='partyflag1'>报名中</span>";break;
		case 2:$flag_str = "<span class='partyflag2'>进行中</span>";break;
		case 3:$flag_str = "<span class='partyflag3'>圆满结束</span>";break;
	}
	return $flag_str;
}
?>
<!doctype html><html><head><meta charset="utf-8">
<title><?php echo $title;?><?php echo $_ZEAI['siteName'];?></title>
<?php echo HEADMETA; ?>
<meta name="generator" content="Zeai.cn V9" />
<meta name="Keywords" content="<?php echo $title;?>">
<meta name="Description" content="<?php echo $content;?>">
<link href="<?php echo RES;?>m/css/m.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<link href="<?php echo RES;?>m/css/party_detail.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<link href="<?php echo HOST;?>/cache/zeaicolor.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<script src="<?php echo RES;?>www_zeai_cn.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="<?php echo RES;?>m/js/m.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="<?php echo RES;?>m/js/party_detail.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<style>
.party_detail .tabmenuParty .ed span{color:#333}
#backtop a,.party_detailBtmBM a i{color:<?php echo $_ZEAI['mob_mbcolor'];?>}
.party_detail .tabmenuParty i,.party_detailBtmBM a:last-child{background-color:<?php echo $_ZEAI['mob_mbcolor'];?>}
.party_detail .djs{background-color:<?php echo $_ZEAI['mob_mbcolor'];?>}
.party_detail .h5h5 {;box-shadow: 0 0 1.5rem rgb(0 0 0 / 5%)}
</style>
</head>
<body>
<?php
if($submitok == 'ajax_bm_add' || $submitok == 'ajax_bm_add_update_pay'){
	$mini_class='top_mini4';// zeaibg bgcolor
	$mini_L = '<em onClick="zeai.back()"><i class="ico" >&#xeaca;</i></em>';
	require_once ZEAI.'m/top_mini.php';
}
/*****报名******/
if($submitok == 'ajax_bm_add'){//step 2
	if(ifint($cook_uid)){
		$row = $db->ROW(__TBL_USER__,"sex,mob,truename,birthday,weixin","id=".$cook_uid,"name");
	}
	?>
	<style>
	.TRnav_btn i{color:<?php echo $_ZEAI['mob_mbcolor'];?>}
    .party_detail_bm .button_btm button{background-color:<?php echo $_ZEAI['mob_mbcolor'];?>}
    </style>
	<div class="party_detail_bm">
    	<div class="ptitle" style="display:nonee"><?php echo dataIO($rowf['title'],'out');?></div>
        <form id="Www_Zeai_cn_PartyBm">
            <dl><dt>手机</dt><dd><input name="mob" id="mob" class="input W100_" value="<?php echo dataIO($row['mob'],'out');?>" placeholder="请输入手机号码" autocomplete="off" maxlength="11" pattern="[0-9]*" /></dd></dl>
            <dl><dt>验证码</dt><dd class="yzmF"><input name="verify" id="verify" class="input W100_"  placeholder="输入手机验证码" autocomplete="off" maxlength="4" pattern="[0-9]*" /><a href="javascript:;" class="yzmbtn" id="yzmbtn">获取验证码</a></dd></dl>
            <dl><dt>姓名</dt><dd><input name="truename" id="truename" class="input W100_" value="<?php echo dataIO($row['truename'],'out');?>" placeholder="请输入真实姓名"  autocomplete="off" onBlur="rettop();" maxlength="20" /></dd></dl>
            <dl><dt>性别</dt><dd>
                <input type="radio" name="sex" id="sex1" class="radioskin" value="1"<?php echo ($row['sex'] == 1)?' checked':'';?>><label for="sex1" class="radioskin-label"><i class="i2"></i><b class="W50 S16">男</b></label>　
                <input type="radio" name="sex" id="sex2" class="radioskin" value="2"<?php echo ($row['sex'] == 2)?' checked':'';?>><label for="sex2" class="radioskin-label"><i class="i2"></i><b class="W50 S16">女</b></label>　
            </dd></dl>
            <dl><dt>生年</dt><dd><input name="birthday" id="birthday" class="input W100_" value="<?php echo substr($row['birthday'],0,4);?>" autocomplete="off" maxlength="4" pattern="[0-9]*" placeholder="出生年份，如：1992" onBlur="rettop();" /></dd></dl>
            <dl class="linee"><dt>微信</dt><dd><input name="weixin" id="weixin" class="input W100_" value="<?php echo dataIO($row['weixin'],'out');?>"  placeholder="请输入微信号" maxlength="30" onBlur="rettop();" /></dd></dl>
            <input type="hidden" name="fid" value="<?php echo $fid;?>" />
            <input name="submitok" type="hidden" value="ajax_bm_add_update" />
        </form>
        <div class="button_btm"><button type="button" id="party_detail_bm_btn" class="btn size4 zeaibg" style="box-shadow:0 3px 8px rgba(<?php echo c16_rgb($_ZEAI['mob_mbcolor']);?>,.4)">开始报名</button></div>
        
	</div>
    
        <div class="linebox" style="z-index:0"><div class="line W50 BAI "></div><div class="title S12 BAI">温馨提醒</div></div>
        <div class="ys">以上信息仅用于活动报名联系通知，不对外公开</div>
    <script>
	party_detail_bm_btn.onclick=function(){party_detail_bm_btnFn();}
	zeai.setScrollTop(0);
	function rettop(){zeai.setScrollTop(0);}
	if (!zeai.empty(o('yzmbtn'))){
		yzmbtn.onclick = function(){
			if (zeai.ifmob(o('mob').value)){
				if (!this.hasClass('disabled')){
					yzmbtn.addClass('disabled');
					zeai.ajax({'url':MHOST+'/party_detail'+zeai.extname,'data':{submitok:'ajax_get_verify_self',mob:o('mob').value,fid:<?php echo $fid;?>}},function(e){
						var rs=zeai.jsoneval(e);
						if (rs.flag == 1){
							zeai.msg(rs.msg,{time:3});
							o('verify').value='';
							yzmtimeFn(30);
						}else{
							zeai.msg(rs.msg,mob);
							yzmbtn.removeClass('disabled');
						}
					});
				}
			}else{
				zeai.msg('请输入手机号码',mob);
				return false;
			}
		}
	}
    </script>
	<?php
	require_once ZEAI.'m/TRnav.php';
	exit('</body></html>');
}elseif($submitok == 'ajax_bm_add_update_pay'){//step3付款
	$rowf = $db->ROW(__TBL_PARTY__,"ifpay,rmb_n,rmb_r,title","flag<>3 AND id=".$fid,'name');
	if (!$rowf)json_exit(array('flag'=>0,'msg'=>'活动已经结束'));
	$row2 = $db->ROW(__TBL_PARTY_USER__,"ifpay,truename","mob='".$cook_mob."' AND mob<>'' AND fid=".$fid,'name');
	if (!$row2)json_exit(array('flag'=>0,'msg'=>'你从哪来的呢？你还没有报名吧'));
	if($row2['ifpay']==1)json_exit(array('flag'=>0,'msg'=>'您已经交过费用了'));
	$truename = trimhtml(dataIO($row2['truename'],'out'));
	//2020-10-28
	$rowU = $db->ROW(__TBL_USER__,"id","FIND_IN_SET('mob',RZ) AND mob='$cook_mob'","num");
	if($rowU){
		$cook_uid = $rowU[0];
	}
	$cook_uid=intval($cook_uid);
	?>
	<div class="party_detail_bm_pay">
    	<div class="success">
            <i class="ico">&#xe60f;</i>
            <h2><font class="S16"><?php //echo dataIO($cook_truename,'out');?></font><b>恭喜您报名成功</b></h2>
        </div>
        <div class="pay">
        <?php
			$price=($cook_sex==2)?$rowf['rmb_r']:$rowf['rmb_n'];
			$ptitle=trimhtml(dataIO($rowf['title'],'out'));
			if($price>0){?>
                <br><h5 class="C999">本次需交纳 <font class="S16 Cf00"><?php echo $price;?>元</font> 活动费用</h5><br><br>
                <?php if ($rowf['ifpay'] == 1){
					$jumpurl=mHref('party',$fid);?>
                    <br /><br />
                    <button type="button" class="btn size4 zeaibg W80_ yuan" id="party_nextbtn" style="box-shadow:0 3px 8px rgba(<?php echo c16_rgb($_ZEAI['mob_mbcolor']);?>,.4)">支付报名费</button>
                    <br /><br /><br /><br /><a href="<?php echo $jumpurl;?>">暂不支付，先看看</a>
                    <?php if (!ifint($cook_uid)){?><script src="<?php echo HOST;?>/api/zeai_PAY.js?<?php echo $_ZEAI['cache_str'];?>"></script><?php }?>
                    <script>
					party_nextbtn.onclick=function(){<?php
						if (ifint($cook_uid)){
							$row = $db->ROW(__TBL_USER__,"money","id=".$cook_uid,"num");
							if ($row){
								$cook_money= $row[0];
							}else{
								zeaialert('{"title":"非法登录，请联系管理员","btnt":"我知道了","url":"-1"}');
							}?>
							ZeaiM.div_up({obj:czbox,h:<?php echo (is_weixin())?30.5:37.5;?>});
							<?php
						}else{
							$orderid='PARTY-'.$cook_mob.'-'.date("mdHis");?>
							zeai_PAY({money:<?php echo $price;?>,iflogin:0,paykind:'wxpay',tmpid:<?php echo $fid;?>,kind:4,oid:'<?php echo $orderid;?>',title:encodeURIComponent('<?php echo $ptitle.'(手机：'.$cook_mob.'，姓名：'.$truename.')';?>'),return_url:'<?php echo $jumpurl;?>',jumpurl:'<?php echo $jumpurl;?>'});
						<?php }?>
					}
                    </script>
					<?php
					$jump_url = $jumpurl;
					$money = floatval($price);
					$kind  = 4;
					echo '<input type="hidden" id="money" value="'.$money.'">';
					require_once 'my_pay.php';
				}?>
        	<?php }else{?>
                <br><h5 class="S18 C090">您将免费参加此次活动</h5>
                <br /><br /><a href="<?php echo mHref('party',$fid);;?>" class="btn size4 zeaibg W80_ yuan">返回活动页</a>
         <?php }?>
    	</div>
    </div>
    </body></html>
	<?php
	exit;
}
/*********************** detail 显示***************************/
$TRnav_btn='hide';
$party_2 = party_getBmUlist2($fid);
$ifbanner='';
if(!empty($pathlist)){
	$ARR=explode(',',$pathlist);$n=0;
	foreach ($ARR as $V){
		$ifbanner.='<div class="bn_li" bj="'.$n.'"><a><img src="'.UP.smb($V,'b').'"></a></div>';
		$n++;
	}
}?>
<a class="UgobackFix" href="javascript:zeai.back();"><i class='ico'>&#xe602;</i></a>
<div class="Ublack" id="TRnav_btn"><i class="ico">&#xe614;</i></div>
<div class="party_detail" id="main">
	<?php if (!empty($ifbanner)){ ?>
        <div class="bn" id="bn">
            <div class="bn_main"><?php echo $ifbanner; ?></div>
            <div class="bn_ico" id="bn_ico"></div>
        </div>
		<script>var Wbfb=1,Hbfb=0.65,Hico=40;</script>
        <script src="<?php echo RES;?>jq183.js"></script><script src="<?php echo RES;?>m/js/shop_zeai_banner4.js?<?php echo $_ZEAI['cache_str'];?>"></script>
    <?php }else{?>
    	<div class="banner"><img src="<?php echo $path_b_url;?>" class="banner"></div>
    <?php }?>
    <div class="box titleinfo">
        <h1><?php echo $title;?></h1>
        <div class="bmrs2">
            <dl><dt><?php echo $num_n_str;?></dt><dd>邀请男生</dd></dl>
            <dl><dt><?php echo $num_r_str;?></dt><dd>邀请女生</dd></dl>
            <dl><dt><?php echo $rmb_n_str;?></dt><dd>男生费用</dd></dl>
            <dl><dt><?php echo $rmb_r_str;?></dt><dd>女生费用</dd></dl>
        </div>
        <div class="clear"></div>
    </div>
    <div class="h5h5">
		<?php if ($flag == 1){?>
            <div id='djsbox' class="djs" diftime="<?php echo ($jzbmtime-ADDTIME);?>"><i class='ico'>&#xe634;</i><span>报名倒计时</span><font>00</font><span>天</span><font>00</font><span>时</span><font>00</font><span>分</span><font>00</font><span>秒</span></div>
        <?php }
		if(!empty($party_2)){?><ul><?php echo $party_2;?><div class="clear"></div></ul><?php }?>
        <h5>时间：<?php echo $hdtime;?></h5>    
        <h5>地点：<?php echo $address;if (!empty($longitude)){?><span onclick="openmap(<?php echo $longitude;?>,<?php echo $latitude;?>,'<?php echo $title;?>','<?php echo $address;?>')" class="icomap"><i class="ico">&#xe624;</i><font>地图</font></span><?php }?></h5>
    </div>
	<div class="Cbox">
        <div class="tabmenuold tabmenuold_3 tabmenuParty" id="party_detail_nav">
            <li id="party_detail1btn" class="ed"><span>活动介绍</span></li>
            <li id="party_detail3btn"><span>现场签到<?php echo $signum_str;?></span></li>
            <li id="party_detail4btn"><span>评论<?php echo $bbsnum_str;?></span></li>
            <i></i>
        </div>
    	<div class="C">
        	<div class="C1 " id="party_detail_C1">
                <iframe src="article_C.php?t=party&id=<?php echo $fid;?>" frameborder="0" scrolling="no" id="article_C" class="article_C" onload="setArticle_C(this)"></iframe>
                <div class="party_kefu">
                    <div class="linebox"><div class="line"></div><div class="title S14 BAI">活动咨询</div></div><br>
                    遇到问题？请联系客服帮忙。
                    <?php $kf_tel=dataIO($_ZEAI['kf_tel'],'out');$kf_mob=dataIO($_ZEAI['kf_mob'],'out');$kf_qq=dataIO($_ZEAI['kf_qq'],'out');$kf_wxpic=dataIO($_ZEAI['kf_wxpic'],'out'); ?>
                    <?php if (!empty($kf_tel)){?><br><i class="ico">&#xe7c1;</i> <a href="tel:<?php echo $kf_tel;?>"><?php echo $kf_tel;?></a><?php }?>
                    <?php if (!empty($kf_mob)){?><br><i class="ico">&#xe627;</i> <a href="tel:<?php echo $kf_mob;?>"><?php echo $kf_mob;?></a><?php }?>
                    <?php if (!empty($kf_wxpic)){?><img src="<?php echo UP.$kf_wxpic;?>"><font>长按或扫码加客服微信</font><?php }?>
                </div>
            </div>
        	<div class="C2 " id="party_detail_C2">
				<ul class="signlist"><?php echo party_getBMulist($fid,'list')?></ul>
            </div>
        	<div class="C3 " id="party_detail_C3">
            	<ul class="signlist"><?php echo party_getSignUlist($fid)?></ul>
                <br><br><div class="linebox" style="z-index:0"><div class="line BAI W50"></div><div class="title S12 BAI">温馨提醒</div></div><center>【参加活动时，请携带本人身份证到现场签到】</center><br>
            </div>
            <div class="C4 " id="party_detail_C4">
				<div id="party_bbsbox"><?php echo party_getBBSulist($fid);?></div>
                <form id="Www_Z_e_a_i_C_n_Party"><textarea id="content" name="content" class="textarea" placeholder="我想说两句...请文明发言~~" onBlur="zeai.setScrollTop(0);"></textarea>
				<input name="fid" type="hidden" value="<?php echo $fid;?>" />
                <input name="submitok" type="hidden" value="ajax_bbs_add_update" />
                </form>
                <button type="button" id="party_bbs_btn" class="btn size3 zeaibg">提交评论</button>
            </div>
        </div>
    </div>
</div>
<div id="backtop"><a href="#top" id="btmTopBtn"><i class="ico">&#xe60c;</i>顶部</a></div>
<div id="partysharebox">
	<li><i class="ico" onClick="copy('【<?php echo $title;?>】这个活动不错，分享给你看看。<?php echo mHref('party',$fid); ?>');">&#xe616;</i><span>复制链接</span></li>
	<li id="zeai_haibaobtn"><i class="ico">&#xea3b;</i><span>生成海报</span></li>
	<li id="wxshare"><i class="ico">&#xe607;</i><span>微信分享</span></li>
</div>
<div class="party_detailBtmBM" id="BtmNav">
    <a href="#content" class="bbs" id="party_bbsbtn"><i class="ico">&#xe676;</i><span>评论</span></a>
    <a class="kefu" id="party_kefubtn"><i class="ico">&#xe68b;</i><span>咨询</span></a>
    <a class="kefu" id="partyshare"><i class="ico">&#xe61d;</i><span>分享</span></a>
    <a id="party_bmbtn"<?php echo $bmbtn_cls;?>><?php echo $bmbtn_str;?></a>
</div>
<div id="share_mask" class="mask1"></div>
<div id="share_box"><img src="<?php echo RES;?>shareico.png"></div>
<div id="card_detail">
	<div class="cardbox">
		<div class="pcard" id="cardcontent">
        	<h4><?php echo $_ZEAI['siteName'];?></h4>
            <em>
            	<div class="partyflagHB"><?php echo partyflag($flag);?></div>
                <h3 class="title"><?php echo $title;?></h3>
                <div class="mpic" style="background-image:url('<?php echo $path_b_url;;?>')"></div>
                <div class="titleinfo">
                    <h5>时间：<?php echo $hdtime;?></h5>    
                    <h5>地点：<?php echo $address;?></h5>
                </div>
            </em>
            <img src="<?php echo HOST.'/sub/creat_ewm.php?url='.mHref('party',$fid);?>" class="card_ewm">

            <img src="<?php echo RES;?>m/img/partyHB.jpg?<?php echo $_ZEAI['cache_str'];?>" class="mb">
		</div>
	</div>
	<div class="cardbox_view" id="cardbox_view"></div>
</div>
<?php require_once ZEAI.'m/TRnav.php';?>
<script src="<?php echo RES;?>html2canvas.js"></script>    
<script src="<?php echo RES;?>html2canvas_img.js"></script>
<script>var fid=<?php echo $fid;?>,ifdetail=true,flag=<?php echo intval($flag);?>;</script>
<?php
if (is_weixin()){
	require_once ZEAI."api/weixin/jssdk.php";?>
	<script src="<?php echo RES; ?>jweixin-1.2.0.js"></script>
	<script>
	wx.config({debug:false,
		appId: '<?php echo $signPackage["appId"];?>',
		timestamp: <?php echo $signPackage["timestamp"];?>,
		nonceStr: '<?php echo $signPackage["nonceStr"];?>',
		signature: '<?php echo $signPackage["signature"];?>',
		jsApiList: ['getLocation','openLocation','hideMenuItems','onMenuShareTimeline','onMenuShareAppMessage','onMenuShareQQ','onMenuShareWeibo']
	});
	var share_party_detail_title = '<?php echo $title; ?>_<?php echo $_ZEAI['siteName'];?>',
	share_party_detail_desc  = '<?php echo dataIO(trimhtml($content),'out',50); ?>',
	share_party_detail_link  = '<?php echo mHref('party',$fid); ?>',
	share_party_detail_imgurl= '<?php echo $path_s_url; ?>';
	wx.ready(function () {
		wx.onMenuShareAppMessage({title:share_party_detail_title,desc:share_party_detail_desc,link:share_party_detail_link,imgUrl:share_party_detail_imgurl});
		wx.onMenuShareTimeline({title:share_party_detail_title,link:share_party_detail_link,imgUrl:share_party_detail_imgurl});
	});
	function openmap (lng,lat,title,address){
		var newgps=b_t(lng,lat);
		lng=parseFloat(newgps[0]);lat=parseFloat(newgps[1]);
		wx.openLocation({
			latitude:lat,
			longitude:lng,
			name:title,
			address:address,
			scale:14,
			infoUrl:'http://weixin.qq.com'
		});
	}
	function b_t(lng,lat) {
		if (lng == null || lng == '' || lat == null || lat == '')return [lng, lat];
		var x_pi = 3.14159265358979324;
		var x = parseFloat(lng) - 0.0065;
		var y = parseFloat(lat) - 0.006;
		var z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * x_pi);
		var theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * x_pi);
		var lng = (z * Math.cos(theta)).toFixed(7);
		var lat = (z * Math.sin(theta)).toFixed(7);
		return [lng,lat];
	}	
	</script>
<?php }else{?>
	<script>function openmap (lng,lat,title,address){zeai.openurl('http://api.map.baidu.com/marker?location='+lat+','+lng+'&title='+address+'&content='+title+'&output=html');	}</script>
<?php }
if (!empty($_GZH['wx_gzh_ewm']) && ifint($cook_uid)){wx_endurl('您刚刚浏览的页面【相亲活动】'.$title,mHref('party',$fid));}
function party_getBMulist($fid,$list='') {
	global $db,$_ZEAI,$cook_grade;
	$rt=$db->query("SELECT photo_ifshow AS Pphoto_ifshow,uid,truename,sex AS Psex FROM ".__TBL_PARTY_USER__." WHERE fid=".$fid." ORDER BY id DESC");
	$total = $db->num_rows($rt);
	if ($total > 0) {
		for($i=1;$i<=$total;$i++) {
			$rows = $db->fetch_array($rt,'name');
			if(!$rows) break;
			$Pphoto_ifshow = $rows['Pphoto_ifshow'];
			$uid           = $rows['uid'];
			$photo_ifshow = 1;
			if(ifint($uid)){
				$row = $db->ROW(__TBL_USER__,"nickname,sex,photo_s,photo_f,photo_ifshow","id=".$uid);
				if ($row){
					$sex      = $row['sex'];
					$photo_s  = $row['photo_s'];
					$photo_f  = $row['photo_f'];
					$photo_ifshow = $row['photo_ifshow'];
					$nickname = trimhtml(dataIO($row['nickname'],'out'));
					$nickname = (empty($nickname))?'uid:'.$uid:$nickname;
					$sexbg = ' class="photo_s"';
					$hidden = ($Pphoto_ifshow==0)?1:0;
					$photo_flag=photo_s_out('{"hidden":"'.$hidden.'","smb":"s","sex":"'.$sex.'","photo_s":"'.$photo_s.'","photo_f":"'.$photo_f.'","photo_ifshow":"'.$photo_ifshow.'","uflag":"'.$uflag.'","outkind":"flag"}');
					$photo_s_url=photo_s_out('{"hidden":"'.$hidden.'","smb":"s","sex":"'.$sex.'","photo_s":"'.$photo_s.'","photo_f":"'.$photo_f.'","photo_ifshow":"'.$photo_ifshow.'","uflag":"'.$uflag.'","outkind":"url"}');
				}
			}else{
				$nickname = trimhtml(dataIO($rows['truename'],'out'));
				$sex      = $rows['Psex'];
				$photo_s_url= RES.'photo_m'.$sex.'.png';
				$nickname = gylsubstr($nickname,1,0,"utf-8",false).'*(匿名)';
				$sexbg = ' class="photo_s"';
			}
			if(!$photo_flag || !ifint($uid)){
				$echo .= '<li>';
			}else{
				$echo .= '<li onClick="PTuA('.$uid.');">';
			}
			$echo .='<img src='.$photo_s_url.' '.$sexbg.'>';
			$echo .= '<span>'.$nickname.'</span>';
			$echo .= '</li>';
		}
	}
	$nodatatips = "<div class='nodatatips' style='margin:20px auto'><i class='ico'>&#xe659;</i><br>暂时还没有人报名</div>";
	$echo = (empty($echo))?$nodatatips:$echo;
	$db->query("UPDATE ".__TBL_PARTY__." SET bmnum=".$total." WHERE id=".$fid);
	
	if($list=='list')return $echo;
	
	//$totalnum = $db->COUNT(__TBL_PARTY_USER__,"fid=".$fid);
	return array('total'=>$totalnum,'list'=>$echo);
}
function party_getBmUlist2($fid) {
	global $db,$_ZEAI;
	$rt=$db->query("SELECT U.sex,U.photo_s,U.photo_f,U.photo_ifshow,U.flag,a.photo_ifshow AS Pphoto_ifshow FROM ".__TBL_PARTY_USER__." a,".__TBL_USER__." U WHERE a.uid=U.id AND U.flag=1 AND a.fid=$fid ORDER BY a.id DESC LIMIT 5");
	$echo = '';$i=0;
	WHILE ($rows = $db->fetch_array($rt,'num')){
		$sex      = $rows[0];
		$photo_s  = $rows[1];
		$photo_f  = $rows[2];
		$photo_ifshow = $rows[3];
		$uflag    = $rows[4];
		$Pphoto_ifshow = $rows[5];
		$hidden = ($Pphoto_ifshow==0)?1:0;
		$photo_s_url=photo_s_out('{"hidden":"'.$hidden.'","smb":"s","sex":"'.$sex.'","photo_s":"'.$photo_s.'","photo_f":"'.$photo_f.'","photo_ifshow":"'.$photo_ifshow.'","uflag":"'.$uflag.'","outkind":"url"}');
		$echo.='<img src="'.$photo_s_url.'">';
		$i++;
	}
	if($i>2)$echo.='<li class="more"><i class="ico">&#xe642;</i></li>';
	return $echo;
}

function party_getSignUlist($fid) {
	global $db,$_ZEAI;
	$rt=$db->query("SELECT a.uid,U.nickname,U.sex,U.grade,U.photo_s,U.photo_f,U.photo_ifshow,U.flag AS uflag FROM ".__TBL_PARTY_SIGN__." a,".__TBL_USER__." U WHERE a.uid=U.id AND U.flag=1 AND a.fid=$fid ORDER BY a.id DESC");
	$echo = '';
	$i=0;
	WHILE ($rows = $db->fetch_array($rt,'name')){
		$i++;
		$uid      = $rows['uid'];
		$sex      = $rows['sex'];
		$photo_s  = $rows['photo_s'];
		$photo_f  = $rows['photo_f'];
		$photo_ifshow = $rows['photo_ifshow'];
		$uflag = $rows['uflag'];
		$grade    = $rows['grade'];
		$nickname = dataIO($rows['nickname'],'out');
		$nickname = (empty($nickname))?'uid:'.$uid:$nickname;
		$photo_s_url=photo_s_out('{"smb":"s","sex":"'.$sex.'","photo_s":"'.$photo_s.'","photo_f":"'.$photo_f.'","photo_ifshow":"'.$photo_ifshow.'","uflag":"'.$uflag.'","outkind":"url"}');		
		$echo .= '<li onClick="PTuA('.$uid.');">';
		$echo .='<img src="'.$photo_s_url.'" class="photo_s">';
		$echo .= '<span>'.$nickname.'</span>';/*uicon($sex.$grade).*/
		$echo .= '</li>';
	}
	$db->query("UPDATE ".__TBL_PARTY__." SET signnum=".$i." WHERE id=".$fid);
	return $echo;
}
function party_getBBSulist($fid) {
	global $db,$_ZEAI;
	$rt=$db->query("SELECT a.uid,a.content,a.addtime,U.nickname,U.sex,U.grade,U.photo_s,U.photo_f,U.photo_ifshow,U.flag AS uflag FROM ".__TBL_PARTY_BBS__." a,".__TBL_USER__." U WHERE a.uid=U.id AND U.flag=1 AND a.fid=$fid ORDER BY a.id DESC");
	$echo = '';
	$i=0;
	WHILE ($rows = $db->fetch_array($rt,'name')){
		$i++;
		$uid      = $rows['uid'];
		$sex      = $rows['sex'];
		$photo_s  = $rows['photo_s'];
		$photo_f  = $rows['photo_f'];
		$uflag    = $rows['uflag'];
		$photo_ifshow = $rows['photo_ifshow'];
		$grade    = $rows['grade'];
		$nickname = dataIO($rows['nickname'],'out');
		$nickname = (empty($nickname))?'id:'.$uid:$nickname;
		$content  = dataIO($rows['content'],'out');
		$photo_s_url=photo_s_out('{"smb":"s","sex":"'.$sex.'","photo_s":"'.$photo_s.'","photo_f":"'.$photo_f.'","photo_ifshow":"'.$photo_ifshow.'","uflag":"'.$uflag.'","outkind":"url"}');		
		$addtime    = date_str($rows['addtime']);
		$echo .= '<dl>';
		$echo .= '<dt onClick="PTuA('.$uid.');"><img src="'.$photo_s_url.'"></dt>';
		$echo .= '<dd>';
		$echo .= '<h6>'.uicon($sex.$grade).'<font>'.$nickname.'</font></h6>';
		$echo .= '<em>'.$content.'</em>';
		$echo .= '<span>'.$addtime.'</span>';
		$echo .= '</dd>';
		$echo .= '</dl>';
	}
	$db->query("UPDATE ".__TBL_PARTY__." SET bbsnum=".$i." WHERE id=".$fid);
	return $echo;
}
?>